package com.looookme.shaozhuo.uicompent;

import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;

/**
 * Created by Shaozhuo on 2015/9/7.
 */
public class Ui_AutoCompleteTextView extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        initView();
    }

    private void initView() {
        LinearLayout linearLayout = new LinearLayout(this);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        setContentView(linearLayout);

        android.widget.AutoCompleteTextView autoCompleteTextView = new android.widget.AutoCompleteTextView(this);
        autoCompleteTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        autoCompleteTextView.setCompletionHint("输入搜索内容");
        autoCompleteTextView.setThreshold(2);
        linearLayout.addView(autoCompleteTextView);

        String[] COUNTRIES = new String[]{"www.baidu.com", "www.looookme.com", "www.sohu.com", "www.taobao.com", "me.looookme.com"};
        autoCompleteTextView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES));
    }
}
